const Koa = require('koa')


// 实例化应用
const app = new Koa()

async function middleware1(ctx, next) {
    console.log('middleware1 start');
    await next()
    console.log('middleware1 end');
}

async function middleware2(ctx, next) {
    console.log('middleware2 start');
    await next()
    console.log('middleware2 end');
}

app.use(middleware1)
app.use(middleware2)

app.use(async (ctx) => {
    console.log('router');
    ctx.body = 'Hello world'
})

app.listen(8899, () => {
    console.log('listen on 8899');
})